package com.design.迭代器模式;

import java.util.ArrayList;
import java.util.List;

public class TestClient {

	public static void main(String[] args) {
		
		/**
		 * 迭代器模式：提供一个方法去顺序防卫一个集合中的元素，而又不暴露这些元素的内部表示
		 * 
		 */
		
		
		
		List<Object> list = new ArrayList<Object>();
		AbstractObjectList abl = new ConcreateObjectList(list);
		abl.add("张三");
		abl.add("李四");
		abl.add("赵武");
		abl.add("王麻子");
		abl.add("周芷若");
		abl.add("张无忌");
		
		AbstractIterator it = abl.createIterator();
		while(!it.isNext()) {
			System.out.println(it.getNext());
			it.next();
		}
		
		System.out.println("------------------------");
		
		while(!it.isFirst()) {
			System.out.println(it.getPrev());
			it.prev();
		}
		
		
		
	}
	
}
